package com.lxl.rabbitmq1.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class DirectConfig {

    @Bean
    public DirectExchange directExchange() {

        //durable是否实例化持久化，autodelete是否自动删除
        DirectExchange directExchange = new DirectExchange("email_direct");//durable是否实例化，autodelete是否自动删除

        return directExchange;
    }

    @Bean
    public Queue emailQueue() {
        Queue queue = new Queue("email_queue");
        return queue;
    }

    @Bean
    Binding bindingEmailQueue() {
        return BindingBuilder.bind(emailQueue()).to(directExchange()).with("email_direct_queue");
    }

}

